// 所有以前在路由里面解构的东西，全部都放在umi里面了
// 和react相关的东西还是在react里面
import { history } from 'umi';
// 引入本地图片，要使用import或者require
import img from '../../assets/a.png';

import { Button } from 'antd';

// import request from 'umi-request';
import { useEffect } from 'react';
import { homeApi } from '@/utils/api';

const Index = () => {
  useEffect(() => {
    // 如果地址是斜杠开头的，默认的前缀是和前端页面相同的前缀
    // request.get('/api/users').then((response) => {
    //   console.log(response);
    // });
    (async () => {
      const res = await homeApi();
      console.log(res);
    })();
  }, []);
  const fn = () => {
    history.push('/about');
  };

  return (
    <div className="title">
      这是首页页面 - <button onClick={fn}>跳转到about</button>
      {/* <img src={require('../../assets/a.png')} alt="" /> */}
      <img src={img} alt="" />
      <hr />
      <Button type="primary">Primary Button</Button>
    </div>
  );
};

Index.title = 'Home Page';

export default Index;
